<template>
    <div>
        <van-nav-bar id="reset" title="今日就诊患者" left-arrow @click-left="backHandle" fixed z-index="100" />

        <div class="pageCon fuPage">

            <div class="listBox">
                <div class="listTop">
                    <span>
                        筛选
                    </span>
                    <div>
                        <span></span>
                        <van-popover v-model="showPopover" trigger="click" theme="dark" :actions="actions"
                            @select="onSelect">
                            <template #reference>
                                {{ type == -1 ? '全部申请' : type == 1 ? '亲情就诊' : '加号申请' }}<van-icon name="bars" />
                            </template>
                        </van-popover>
                    </div>
                </div>
                <div class="listMain">
                    <template v-if="applyList.length != 0">
                        <div class="itemBox" v-for="(item, index) in applyList" :key="index">
                            <div class="orderNumTip">
                                申请编号：{{ item.orderNumber }}
                            </div>
                            <div class="line1">
                                <span>{{ item.userName }}
                                    <span>{{ item.payType == 0 ? '免费' : '付费' }}</span> </span>
                                <span v-if="item.orderStatus == 0">
                                    未审核
                                </span>
                                <span v-if="item.orderStatus == 2" class="resColor">
                                    已驳回
                                </span>
                                <span v-if="item.orderStatus == 1" class="passColor">
                                    已通过
                                </span>
                            </div>
                            <div>
                                <span>您的{{ item.orderType == 0 ? '加号' : '亲情就诊' }}申请</span>
                                <span>{{ item.createTime }}</span>
                            </div>
                            <div class="imgBox" v-if="item.imgList != null && item.imgList.length != 0">
                                <span>相关图片</span>
                                <div>
                                    <img :src="ele.imgUrl" alt="" v-for="(ele, eIndex) in item.imgList" :key="eIndex"
                                        @click="checkImg(item.imgList, eIndex)">
                                </div>
                            </div>
                            <div class="passRea" v-if="item.orderStatus == 1"> <span>就诊时间：{{ item.visitTime
                                    }}</span>
                            </div>
                            <!-- <div class="passRea" v-if="item.orderStatus == 2">
                    驳回原因： {{ item.unPass }}
                </div> -->

                        </div>
                    </template>
                    <div class="emptyBox" v-else>
                        <img src="../../assets/tip_content.png">
                    </div>
                </div>
            </div>
        </div>


    </div>


</template>

<script>
import { listCurrApply } from '../../network/doctor'
export default {
    name: 'HomeR',
    data() {
        return {

            type: -1,// -1全部  1 已使用 0 未使用
            oldList: [],//原始数据
            applyList: [],
            showPopover: false,
            actions: [
                {
                    text: '全部申请',
                    value: -1
                },
                {
                    text: '亲情就诊',
                    value: 1
                },
                {
                    text: '加号申请',
                    value: 0
                }
            ],
        }
    },
    mounted() {

    },
    methods: {
        onSelect(action) {
            console.log(action);
            this.type = action.value


            this.applyList = this.oldList.filter(item => {
                if (this.type == -1) {
                    return item
                } else {
                    return item.orderType == this.type
                }
            })

        },

        apply(obj) {
            this.$dialog.confirm({
                title: '提示',
                message: '是否对该申请进行核销',
                cancelButtonText: '取消',
                confirmButtonText: '确认'
            })
                .then(() => {
                    // on confirm
                    console.log(obj);
                })
                .catch(() => {
                    // on cancel
                });
        },

        toPage(url, obj) {

            if (url == '/applyHistory') {
                this.$router.push(url)
            } else {
                this.$router.push({
                    path: url,
                    query: {
                        userId: obj.userId || 6,
                    },
                });
            }
        },
        backHandle() {
            this.$router.back()
        },


        getOrderList() {
            listCurrApply({
                doctorId: localStorage.userId,
                // doctorId: 25,
            }).then(res => {
                if (res.flag) {
                    this.isLoading = false
                    this.applyList = res.data
                    this.oldList = JSON.parse(JSON.stringify(res.data))
                }
            })
        },

        pullHandle() {

            this.isLoading = true
            this.getOrderList()
        },

        checkImg(list, index) {

            console.log(list);
            var arr = []
            list.forEach(item => {
                arr.push(item)
            })
            console.log(arr);
            ImagePreview({
                images: arr, // 需要预览的图片 URL 数组
                showIndex: true, // 是否显示页码
                closeable: true, // 是否显示关闭图标	
                startPosition: index,
                showIndicators: true
            })
        },




    },
    created() {
        this.getOrderList()

    },
    //计算属性
    computed: {

    },
    filters: {

    },
    watch: {
    }

}

</script>

<style lang='less' scoped>
.pageCon {

    padding: 112px 20px 0 !important;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: #EEF1F7;
    overflow: hidden;
}


.listBox {
    width: 100%;
    height: 100%;

    overflow-y: scroll;
}


.listTop {
    position: sticky;
    top: 0px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    padding: 30px 34px 10px 44px;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 500;
    font-size: 28px;
    color: #333333;
    background: #fff;
}

.listTop>div>span:nth-child(2) {
    margin-left: 30px;
    color: #999999;
}

.itemBox {
    margin-bottom: 20px;
    box-sizing: border-box;
    padding: 44px 30px 44px 44px;
    width: 100%;
    border-bottom: 2px solid #f2f2f2;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0px 2px 6px 0px rgba(51, 51, 51, 0.08);
}

.itemBox>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    font-family: Source Han Sans CN;
    font-weight: 400;
    font-size: 28px;
    color: #333333;
    line-height: 38px;

}

.itemBox>div:nth-child(3) {
    margin-top: 12px;
}

.itemBox>div:nth-child(3)>span {
    font-size: 28px;
    color: #999999;
}

.line1>span>span:nth-child(1) {
    color: #333;
}

.line1>span>span {
    font-size: 24px;
    color: #999999;
}

// .line1>span:nth-child(2) {
//     display: flex;
//     align-items: center;
//     justify-content: center;
//     width: 136px;
//     height: 48px;
//     border-radius: 24px;
//     border: 1px solid rgba(27, 178, 106, .5);
//     font-family: Source Han Sans CN;
//     font-weight: bold;
//     font-size: 20px;
//     color: #1BB26A;
// }


#reset /deep/ .van-nav-bar__left .van-nav-bar__text,
#reset /deep/ .van-nav-bar__right .van-nav-bar__text,
#reset /deep/ .van-nav-bar__left .van-icon {
    color: #333 !important;
}


.emptyBox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.emptyBox>img {
    margin-top: 400px;
    width: 374px;
    height: 314px;
}

.passRea {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #f2f2f2;
    font-size: 28px !important;
    color: #999 !important;
}

.imgBox {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start !important;
    padding-top: 24px;
    border-top: 1px solid #f2f2f2;
    width: 100%;
}

.imgBox>span {
    font-size: 28px;
    color: #999;
}

.imgBox>div>img {
    margin: 16px 16px 16px 0;
    width: 100px;
    height: 100px;
    // background: aqua;
    border-radius: 16px;
}


.resColor {
    color: #F56C6C !important;
}

.passColor {
    color: #67C23A !important;
}

.orderNumTip {
    margin-bottom: 12px;
    width: 100%;
    font-size: 24px;
    color: #333;
}
</style>